package entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.validator.NotNull;

@Entity
@PrimaryKeyJoinColumn(name = "id")
public class BSCGoal extends BSCElement{
	
	@Column(insertable=false, updatable=false)
	private int id;
	
	@NotNull
	private String name;
	
	@ManyToOne(fetch = FetchType.LAZY)
	private BSC_Perspective perspective;
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name="BSCGoal_SWOTElement", joinColumns=@JoinColumn(name="BSCGoal_id"), 
			   inverseJoinColumns=@JoinColumn(name="SWOTElement_id"))
	@Cascade({CascadeType.ALL})	
	private List<SWOTElement> listRelatedSwotElement;
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name="BSCGoal_BSCMetric", joinColumns=@JoinColumn(name="BSCGoal_id"), inverseJoinColumns=@JoinColumn(name="BSCMetric_id"))
	@Cascade({CascadeType.ALL})
	private List<BSCMetric> metrics;
	
	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name="StrategicAction_BSCGoal", joinColumns = @JoinColumn(name="BSCGoal_id"), inverseJoinColumns=@JoinColumn(name="StrategicAction_id"))
	@Cascade({CascadeType.ALL})
	private List<StrategicAction> actions;
	
	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setPerspective(BSC_Perspective perspective) {
		this.perspective = perspective;
	}

	public BSC_Perspective getPerspective() {
		return perspective;
	}

	public void setListRelatedSwotElement(List<SWOTElement> listRelatedSwotElement) {
		this.listRelatedSwotElement = listRelatedSwotElement;
	}

	public List<SWOTElement> getListRelatedSwotElement() {
		return listRelatedSwotElement;
	}

	public void setMetrics(List<BSCMetric> metrics) {
		this.metrics = metrics;
	}

	public List<BSCMetric> getMetrics() {
		return metrics;
	}

	public void setActions(List<StrategicAction> actions) {
		this.actions = actions;
	}

	public List<StrategicAction> getActions() {
		return actions;
	}
}
